package com.john.params;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.Min;

/**
 * 分页参数对象父类
 * 日期 2021/5/27 16:27
 * 创建者：john driver
 */
@Data
@ApiModel(value = "分页数据", description = "分页需要的表单数据")
public class PageParam{
    @ApiModelProperty(value = "页码 从第一页开始 1")
    @Min(value = 1, message = "页码输入有误")
    private Integer current;


    @ApiModelProperty(value = "每页显示的数量 范围在1~100")
    @Range(min = 1, max = 100, message = "每页显示的数量输入有误")
    private Integer size;


    @ApiModelProperty(hidden = true)
    public Integer calcStart(){
        return (current - 1 ) * size;
    }
}
